package com.shigen.springcloud.entity;

import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T> implements Serializable {

  private Integer code;
  private String message;
  private T data;

  public CommonResult(Integer code, String message) {
    this(code, message, null);
  }

  public static <T> CommonResult success(String message, T data) {
    return new CommonResult(200, message, data);
  }

  public static <T> CommonResult error(String message, T data) {
    return new CommonResult(400, message, data);
  }
}
